import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// //获取原型对象上的push函数
// const originalPush = Router.prototype.push
// //修改原型对象中的push方法
// Router.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }
export default new VueRouter({
  routes: [
    {
      path: '/',
      name: 'Index',
      redirect: '/index',
    },
    {
      path: '/index',
      component: () => import('../views/index.vue'),
    },
    {
      path: '/declare',
      name: 'Declare',
      component: () => import('../views/declare.vue'),
    },
    {
      path: '/myDeclare',
      name: 'MyDeclare',
      component: () => import('../views/myDeclare.vue'),
    },
    {
      path: '/enterprise',
      name: 'Enterprise',
      component: () => import('../views/enterprise.vue'),
    },
    {
      path: '/formalExamination',
      name: 'FormalExamination',
      component: () => import('../views/formalExamination.vue'),
    },
    {
      path: '/expertReview',
      name: 'ExpertReview',
      component: () => import('../views/expertReview.vue'),
    },
    {
      path: '/index/projectDetails',
      name: 'ProjectDetails',
      component: () => import('../views/index/projectDetails.vue'),
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('../views/index/register.vue'),
    },
    {
      path: '/index/declareDetails',
      name: 'DeclareDetails',
      component: () => import('../views/index/declareDetails.vue'),
    },
    {
      path: '/declare/noticeDetails',
      name: 'NoticeDetails',
      component: () => import('../views/declare/noticeDetails.vue'),
    },
    {
      path: '/index/applyDeerAward',
      name: 'ApplyDeerAward',
      component: () => import('../views/index/applyDeerAward.vue'),
    },
    {
      path: '/index/highVideoReport',
      name: 'highVideoReport',
      component: () => import('../views/highVideoReport'),
    },
    {
      path: '/index/highVideoBroadcast', // 高清播出路由页面
      name: 'highVideoBroadcast',
      component: () => import('../views/highVideoBroadcast'),
    },
    {
      path: '/index/jlhighVideoBroadcast', // 金🦌
      name: 'jlhighVideoBroadcast',
      component: () => import('../views/jlhighVideoBroadcast'),
    },
    {
      path: '/index/jlhighVideoReport', // 金🦌
      name: 'jlhighVideoReport',
      component: () => import('../views/jlhighVideoReport'),
    }
  ],
  /**
   *  vue 滚动行为
   * @param {*} to
   * @param {*} from
   * @param {*} savedPosition  在按下 后退/前进 按钮时，就会像浏览器的原生表现那样
   * @returns
   */
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      // 触发浏览器 前进/返回
      return savedPosition
    } else {
      return { x: 0, y: 0 } // x轴y轴归零
    }
  },
})
